#include <winsock2.h>
#include <ws2tcpip.h>
#include <process.h>
#include <winsock.h>
#include <iostream>
#include <string>
#include <list>
#include "Thread.h"

/*
Used by the server to keep track of clients. Each runs in its own thread.
*/

class ClientThread : public Thread
{
public:
	ClientThread(SOCKET hClientSocket, const sockaddr_in &sockAddr); 
//	std::string GetHostDescription(const sockaddr_in &sockAddr);
	virtual void run();
	void Terminate();
private:
	void HandleMessage(char* msg); //figures out what to do with a string sent by the user
	void WaitForAcknowledge();
	void SendFolderContents();
	std::list<std::string>* ListDirectoryContents(const char *sDir);
	bool WaitForSuccessOrFailure();//suspend thread until the other party returns a "success" or "fail"

	SOCKET _clientSocket;
	sockaddr_in _sockAddr;
};

